package com.game.majiang.algorithm;

import java.math.BigDecimal;
import java.util.Random;

public class MathHelper {
	public static int Rounding(double in)
	{
		int out = 0;
		String c=in+"";
		BigDecimal cc=new BigDecimal(c).setScale(0, BigDecimal.ROUND_HALF_UP);//四舍五入
		out=cc.intValue();//转换int
		return out;
	}
	public static int Rounding2(double in)
	{
		int out = 0;
		String c=in+"";
		BigDecimal cc=new BigDecimal(c).setScale(0, BigDecimal.ROUND_DOWN);
		out=cc.intValue();//转换int
		return out;
	}
	public static int Random2(int min, int max)
	{
		max++;
		if(max < min)
		{
			return min;
		}
		if(min == max)
		{
			return min;
		}
		Random r = new Random();
		int a = r.nextInt(max-min);	
		return min+a;
	}
}
